package com.nbjtjc.safe.mapper.edu;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.nbjtjc.safe.model.edu.EduCertificate;
import com.nbjtjc.safe.model.edu.EduCertificateRetrain;
import com.nbjtjc.safe.model.edu.EduRequirementInvestigation;
import com.nbjtjc.util.MyMapper;
@Mapper
public interface EduCertificateRetrainMapper extends MyMapper<EduCertificateRetrain> {
	@Select("select * from edu_certificate_retrain where edu_certificate_id = #{eduCertificateId}")
	List<EduCertificateRetrain> findByCertificateId(@Param("eduCertificateId")int eduCertificateId);
	@Delete("delete from edu_certificate_retrain where edu_certificate_id = #{eduCertificateId}")
	int deleteByEduCertificateId(@Param("eduCertificateId") int eduCertificateId);
	
//	@Update("UPDATE edu_certificate SET `retrain_date`=(SELECT MAX(retrain_record) FROM edu_certificate_retrain WHERE edu_certificate_id = #{id}) WHERE id=#{id}")
//	int updateRetrain(@Param("id") int id);
	
	
//    @Select("select distinct date_format(retrain_record,'%Y') as 'year' from edu_certificate_retrain where retrain_record is not null")
//    List<String> findYear();
    @Select("SELECT DISTINCT DATE_FORMAT(a.retrain_record,'%Y') AS 'year' FROM edu_certificate_retrain a INNER JOIN edu_certificate b ON  a.edu_certificate_id = b.id WHERE a.retrain_record is not null and b.company_id = #{companyId}")
    List<String> findYear(@Param("companyId")Integer companyId);
}